Dlock

Section: Jan. 8, 1993 (2)
Updated: MiNT Programmer's Manual
Index Return to Main Contents
 

NAME

Dlock - lock or unlock a BIOS disk device  

SYNOPSIS

LONG Dlock( WORD mode, WORD drv );
 

DESCRIPTION

Dlock is used to lock or unlock the BIOS device indicated by drv. No GEMDOS file operations are permitted on a locked drive. Thus, the Dlock call provides a mechanism for disk formatters or re-organizers to lock out other processes while low-level BIOS or XBIOS operations are in progress on the device.

If bit 0 of mode is 1, the drive is locked; if it is 0 then the drive is unlocked and may be used again by other programs. If a process terminates while holding a lock on a drive, that drive is automatically unlocked.

Bit 1 of mode indicates what return values are desired. If this bit is 1, and if the drive is locked by a user process different from the caller, or if some process has files open on the drive, then that process' id will be returned (see below). This may be used to report a more useful error message to the user (by telling him or her which process is using the drive in question when a lock operation fails).

All other bits of mode are reserved and must be set to 0.

A lock operation followed immediately by an unlock is very similar to a media change, except that the lock operation will fail if there are open files that refer to the indicated drive.  

RETURNS

0 if the lock/unlock operation was successful

EDRIVE if drv is not a valid BIOS device number

For a lock operation, the following error codes may be returned:

A positive process id if bit 1 of mode is set, and the drive is already locked or in use by another user process.

EACCDN if bit 1 of mode is clear and either open files exist on the drive or another process is searching a directory on the drive, or if bit 1 of mode is set and the drive is in use by the operating system.

ELOCKED if bit 1 of mode is clear and another process has locked the drive, or if bit 1 of mode is set and the operating system has locked the drive.

For an unlock operation the following error codes may be returned:

ENSLOCK if mode is 0 and the drive was not locked by this process  

SEE ALSO

Fxattr(2)  

NOTES

Note that Dlock operates on BIOS devices, which may not always be in 1-1 correspondence with GEMDOS drive letters. For this reason, to lock GEMDOS drive A: (for example), the programmer should call Fxattr on the root directory of A: ("A:\") and then use the dev field of the structure returned in order to determine the BIOS device corresponding to the GEMDOS drive.  

BUGS

All GEMDOS operations are forbidden on a locked drive, even by the process that created the lock. It would be useful to have a mode which allowed the locking process (and only the locking process) to still make GEMDOS calls on the drive, but unfortunately the structure of the OS makes this difficult; there is also the above-mentioned difference between BIOS and GEMDOS devices to consider.


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURNS
SEE ALSO
NOTES
BUGS

This document was created by man2html, using the manual pages.
Time: 11:14:08 GMT, June 22, 2025